﻿#ifndef XRTCCLIENT_BASE_XRTC_ENGINE_H_
#define XRTCCLIENT_BASE_XRTC_ENGINE_H_

#include "xrtc/ixrtc_engine.h"

#include <modules/video_capture/video_capture.h>
#include <modules/audio_device/include/audio_device.h>

namespace xrtc {

class XRTCEngine : public IXRTCEngine {
public:
    XRTCEngine();
    ~XRTCEngine() override;

    // 获取视频设备列表信息
    virtual std::vector<XRTCDeviceInfo> GetVideoDeviceList() override;

    // 获取音频设备列表信息
    virtual std::vector<XRTCDeviceInfo> GetAudioDeviceList() override;

    // 创建一个视频源
    virtual IXRTCVideoSource* CreateVideoSource(const XRTCVideoConfig& video_config) override;
   
    // 销毁视频源
    virtual void DestroyVideoSource(IXRTCMediaSource* video_source) override;

    // 创建视频预览对象
    virtual IXRTCPreview* CreatePreview(IXRTCVideoSource* video_source,const XRTCCanvas& canvas) override;
  
    // 销毁视频预览对象
    virtual void DestroyPreview(IXRTCPreview* preview) override;

    // 创建推流对象
    virtual IXRTCPusher* CreatePusher() override;
    
    // 销毁推流对象
    virtual void DestroyPusher(IXRTCPusher* pusher) override;

    // 创建拉流对象
    virtual IXRTCPlayer* CreatePlayer() override;

    // 销毁拉流对象
    virtual void DestroyPlayer(IXRTCPlayer* player) override;

private:
    std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> video_device_;
    rtc::scoped_refptr<webrtc::AudioDeviceModule> audio_device_;
};

} // namespace xrtc

#endif // XRTCCLIENT_BASE_XRTC_ENGINE_H_